<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-bind的指令</title>
    <style>
        #dd {
            width: 100px;
            height: 100px;
            border-radius: 50%;
        }

        .color {
            background-color: blue;
        }

        .color.red {
            background-color: red;
        }

        .color.green {
            background-color: green;
        }

        .color.yellow {
            background-color: yellow;
        }
    </style>
</head>

<body>
    <div id="app">
        <h1>{{msg}}</h1>
        <img :src="imgSrc" alt="" width="50px">
        <button @click="changeImg">切换图片</button>
        <div id="dd" :class="calssColor" @click="changeColor"> </div>
    </div>

</body>
<script src="./js/vue.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            msg: 'v-show v-if的指令',
            imgSrc: "./imgs/G病毒.webp",
            calssColor: "color"
        }, methods: {
            changeImg() {
                alert("切换图片")
                this.imgSrc = "./imgs/ComfyUI_00008_lqpop_1760787417.png"
            },
            changeColor() {
                if (this.calssColor == "color") {
                    this.calssColor = "color red"
                } else if (this.calssColor == "color red") {
                    this.calssColor = "color green"
                } else if (this.calssColor == "color green") {
                    this.calssColor = "color yellow"
                } else {
                    this.calssColor = "color"
                }
            }
        }
    })
</script>

</html>